<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
	<title>JavaScript, Limited Execution Pattern</title>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
	<script type="text/javascript" src="jsLimit.js"></script>
	<script type="text/javascript">
		var counts = 0;
		var handlerFunc = function(e) {
			var counter = $('#counter');
			counts++;
			counter.html(counts);
			return false;
		};
		var limitedFunc = handlerFunc.limit(1);
		
		$(function(){
			$('a').bind('click', limitedFunc);
		});
	</script>
</head>

<body>
	<a href="#">Click me rapidly</a>
	<p>Handler called <span id="counter">0</span> times.</p>	
</body>

</html>